<%@tag pageEncoding="UTF-8"%>
<%@attribute name="list" type="java.util.Collection" required="true" description="属性列表" %>
<%@attribute name="name" type="String" required="true" description="name属性，必须"%>
<%@attribute name="id" type="String" description="ul 的id,可选"%>
<%@attribute name="clazz" type="String" description="ul标签的 class属性"%>
<%@attribute name="selected" type="String" description="被选中的复选框 11,12,13"%>
<%@attribute name="labelAttr" type="String" description="标签属性名"%>
<%@attribute name="valueAttr" type="String" description="值属性名"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="idStr" value=""/>
<c:if test="${not empty id }">
    <c:set var="idStr" value="id='${id }'"/>
</c:if>
<c:if test="${empty valueAttr }">
    <c:set var="valueAttr" value="value"/>
</c:if>
<c:if test="${empty labelAttr }">
    <c:set var="labelAttr" value="label"/>
</c:if>
<c:if test="${not empty selected }">
    <c:set var="checkedArr" value="${fn:split( selected, ',')}"/>
</c:if>
<c:forEach items="${list}" var="each" varStatus="var">
    <c:set var="select" value=""/>
    <c:forEach items="${checkedArr}" var="checked">
        <c:if test="${checked eq each[valueAttr]}">
            <c:set var="select" value="checked=\"checked\""/>
        </c:if>
    </c:forEach>
    <label class="${empty clazz ? 'checkbox-inline' : clazz}">
        <input type="checkbox" name='${name }' class="ace" ${select} value="${each[valueAttr] }">
        <span class="lbl"> ${each[labelAttr]}</span>
    </label>
</c:forEach>